package DesignPattern;

public class FactoryMethodPattern {
    interface Product {
        void use();
    }

    class ConcreteProductA implements Product {
        public void use() {
            System.out.println("Using Product A");
        }
    }

    class ConcreteProductB implements Product {
        public void use() {
            System.out.println("Using Product B");
        }
    }

    abstract class Creator {
        public abstract Product factoryMethod();
    }

    class CreatorA extends Creator {
        public Product factoryMethod() {
            return new ConcreteProductA();
        }

    }

    class CreatorB extends Creator {
        public Product factoryMethod() {
            return new ConcreteProductB();
        }
    }
}
